package com.Thread02.demo06;

import java.util.concurrent.Semaphore;

public class MyRnnuer implements Runnable {
    private Semaphore sm = new Semaphore(2);

    @Override
    public void run() {

        try {
            sm.acquire();
            System.out.println("获得了通行证已通过");
            Thread.sleep(1000);
            System.out.println("归还了通行证");
            sm.release();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
